//priority 10000
function LootHelper(/**@type {Internal.LivingEntityDropsEventJS}*/dropEvent) {
    /**@type {Internal.LivingEntityDropsEventJS}*/
    this.event = dropEvent
    /**@type {Internal.LivingEntity}*/
    this.killer = dropEvent.entity.getKillCredit()
}

/**
 * @param {Internal.ItemStack_} ItemStack_
 * @param {Number} Chance_
*/
LootHelper.prototype.add = function (ItemStack_, Chance_) {
    if (this.killer instanceof $Player) {
        var luck = playerHelper.getTotalLuck(this.killer)
        var ItemStack = Item.of(ItemStack_)
        var Chance=Chance_
        if (Chance_ < 0.20) {
            Chance = Math.min(Chance_ * (1 + luck / 100), 0.5)
        }
        var nextFloatRandom = this.killer.random.nextFloat()
        if (nextFloatRandom < Chance) {
            if (Chance_<0.10) {
                this.killer.tell([Component.join([Component.ofString("稀有掉落! ").setStyle($Style.EMPTY.withBold(true)).color(ItemStack.getDisplayName().style.color), Component.of(ItemStack.getDisplayName())]).hover(Component.ofString(Chance*100 + "% " + playerHelper.getTotalLuck(this.killer)+"幸运加成").blue())])
            }
            this.event.addDrop(ItemStack, 1)
        }
    }
}